package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.EmployeeBean;
import com.project.mapper.IEmployeeMapper;
import com.project.mapper.IProcessMapper;
import com.project.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.util.List;
@Service
@Transactional
public class EmployeeServiceImpl implements IEmployeeService {
    @Autowired
    private IEmployeeMapper mapper;
    @Autowired
    IProcessMapper prMapper;


    @Override
    public PageInfo<EmployeeBean> findByItem(int pageNum, String name, String job, String status, String rule) {
        PageHelper.startPage(pageNum,PAGESIZE);
        PageInfo<EmployeeBean>info=PageInfo.of(
                mapper.findByItem(name,job,status,rule)
        );
        return info;
    }

    @Override
    public void add(EmployeeBean employeeBean) {
        mapper.add(employeeBean);

    }

    @Override
    public void updateS(int id, String status) {
        mapper.updateS(id,status);
        prMapper.finishProject(id, LocalDate.now());


    }

    @Override
    public void updateM(int id, String phone, int money) {
        mapper.updateM(id,phone,money);

    }

    @Override
    public EmployeeBean findById(int id) {
        return mapper.findById(id);
    }

    @Override
    public List<EmployeeBean> findOther(int Id, String name, String job) {
        return mapper.findOther(Id, name, job);
    }

    @Override
    public EmployeeBean findByIdRuntime(int id) {
        return mapper.findByIdRuntime(id);
    }
}
